package com.sunlee.common.service.service;

import com.sunlee.common.core.entity.PageData;
import com.sunlee.common.service.dto.ProductActionDTO;
import com.sunlee.common.service.dto.UserActionCountDTO;
import com.sunlee.common.service.dto.UserActionDTO;
import com.sunlee.common.service.dto.UserActionDetailDTO;
import com.sunlee.common.service.dto.req.UserActionDetailReqDTO;
import com.sunlee.common.service.entity.UserActionEntity;

import java.util.List;
import java.util.Map;

/**
 * 用户行为表
 *
 * @author sunlee
 */
public interface UserActionService extends CrudService<UserActionEntity, UserActionDTO> {

    int userRecordById(Long userId, Long pId, int actionType);

    String downloadById(Long userId, Long pId);

    Boolean collectionById(Long userId, Long pId, Integer status);

    Boolean previewById(Long userId, Long pId);

    UserActionCountDTO countByUserId(Long userId);

    PageData<UserActionDetailDTO> listByType(Long userId, UserActionDetailReqDTO dto);

    /**
     * 根据商品集合ID，查询商品对应的下载数、浏览数、收藏数
     *
     * @param pIds 商品集合
     * @return 统计数
     */
    Map<Long, ProductActionDTO> getProductActionDataByIds(List<Long> pIds);

    Boolean updateByIdAndUserId(Long id, Long uId, Long status);
}
